<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const promise = new Promise((resolve, reject) => {
        resolve('成功');
        console.log('before Error')
        //promise中 resolve和reject后的Error不能被捕获。
        throw new Error();
        console.log('after Error')
      })

      promise.then(console.log).catch(error => {
        console.log("error", error)
      })
      window.onerror = (e) => {
        console.log("window.onerror -> e", e)
      }
      window.onrejectionhandled = e => {
        console.log("e", e)
      }
    </script>
  </body>
</html>
